package com.guoqi.keepsign.base

import android.os.Bundle
import android.support.v4.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup

open class BaseFm : Fragment() {

    val TAG = javaClass.simpleName
    protected var mCommomAdapter: CommonAdapter? = null
    protected var mCommonBean: CommonBean? = null
    var rootView: View? = null

    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
        if (rootView == null) {
            rootView = inflater?.inflate(initLayout(), container, false)
        }
        return rootView
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        initUI()
        loadData()
    }

    override fun onHiddenChanged(hidden: Boolean) {
        super.onHiddenChanged(hidden)
        if (!hidden)
            loadData()

    }


    open fun initLayout(): Int {
        return 0
    }

    open fun initUI() {}
    open fun loadData() {}

}
